import Vue from 'vue'
import VueRouter from 'vue-router'

const Home = () => import('../views/Index/Home')             //主界面
const Songlist = () => import('../views/Songlist/Songlist')  //歌曲列表
const Album = () => import('../views/Songlist/Album')  //歌曲列表
const user = () => import('../views/Songlist/User/User')     //用户界面
const Error = () => import('../views/Error/Error')           //错误页面
const Search = () => import('../views/Search/Search')        //搜索
const Mv = () => import('../views/Mv/Mv')                    //MV·
const Video = () => import('../views/Mv/Video')              //推荐视频
const Mymusic = () => import('../views/Top/Mymusic/Mymusic')  //我的音乐
const Firend = () => import('../views/Top/Firend/Friend')     //我的朋友
const Shop = () => import('../views/Top/Shop/Shop')           //商城
const Musician = () => import('../views/Top/Musician/Musician') //音乐人
const Download = () => import('../views/Top/Download/Download')//下载页面
//子路由
const SearchSong = () => import('../views/Search/Children/Song')
const SearchSing = () => import('../views/Search/Children/sing')
const SearchAlbum = () => import('../views/Search/Children/album')
const SearchVideo = () => import('../views/Search/Children/video')
const SearchWords = () => import('../views/Search/Children/words')
const SearchList = () => import('../views/Search/Children/list')
const SearchAnchor = () => import('../views/Search/Children/anchor')
const SearchUser = () => import('../views/Search/Children/user')
const Login = () => import('../views/Login/Login')
const LickMusic = () => import('../views/Top/Mymusic/Songlist/LickMusic')
const MySongList = () => import('../views/Top/Mymusic/Songlist/MySongList')
Vue.use(VueRouter)

const routes = [
  {path: '/', component:Home ,meta:{title:"抑郁云官网"}},
  {path: '/home', component:Home, meta:{title:"抑郁云官网"},children:[
      {path:'login',component:Login,meta: {title:'登录',name:'登录'}}
    ]},
  {path: '/songlist/:id', component:Songlist, meta:{title:"榜单"}},
  {path: '/album/:id', component:Album, meta:{title:"榜单"}},
  {path: '/user/:id', component:user, meta:{title:"用户"}},
  {path: '/error', component:Error, meta:{title:"错误页面"}},
  {path: '/mv/:id', component:Mv, meta:{title:"MV页面"}},
  {path: '/video/:id', component:Video, meta:{title:"video页面"}},
  {path: '/search',component:Search,meta:{title: '搜索',name:'search'},
    children:[
      {path:'song',component:SearchSong,meta:{title: '歌曲',name:'search'}},
      {path:'sing',component:SearchSing,meta:{title: '歌手',name:'search'}},
      {path:'album',component:SearchAlbum,meta:{title: '专辑',name:'search'}},
      {path:'video',component:SearchVideo,meta:{title: '视频',name:'search'}},
      {path:'words',component:SearchWords,meta:{title: '歌词',name:'search'}},
      {path:'list',component:SearchList,meta:{title: '歌单',name:'search'}},
      {path:'anchor',component:SearchAnchor,meta:{title: '声音主播',name:'search'}},
      {path:'user',component:SearchUser,meta:{title: '用户',name:'search'}},
    ]
  },//子路由

  {path: '/mymusic',component:Mymusic,meta: {title: '我的音乐',name: '我的音乐'},
      children: [
        {path: 'lickmusic/:id',component:LickMusic,meta:{title: "喜欢的音乐",name:"喜欢的音乐"}},
        {path: 'mysonglist/:id',component:MySongList,meta:{title: "喜欢的音乐",name:"喜欢的音乐"}},
      ]
  },
  {path: '/firend',component:Firend,meta: {title: '我的朋友',name: '我的朋友'}},
  {path: '/shop',component:Shop,meta: {title: '商城',name: '商城'}},
  {path: '/musician',component:Musician,meta: {title: '音乐人',name: '音乐人'}},
  {path: '/download',component:Download,meta: {title: '下载页面',name: '下载页面'}},
]
const router = new VueRouter({
  routes,
  mode: 'history',
  linkActiveClass:'first'
})

router.beforeEach((to,from ,next)=>{
  document.title = to.matched[0].meta.title;
  next() //放行
})
export default router
